package org.com.yz.dubbo.web.ctrl;

import com.alibaba.dubbo.config.annotation.Reference;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringEscapeUtils;
import org.com.yz.common.annotion.Parameter;
import org.com.yz.common.constant.PayConstant;
import org.com.yz.common.util.ClassRefUtil;
import org.com.yz.common.util.MyLog;
import org.com.yz.common.util.XXPayUtil;
import org.com.yz.dal.dao.model.MchsubQueryEs;
import org.com.yz.dubbo.api.service.IMchsubQueryService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 子商户查询接口控制类
 *
 * @ClassName SelectMachAccNoCtr
 * @Author wzc
 * @Date 2018/7/20 15:34
 **/
@RestController
public class SelectMachAccNoCtr {

    @Reference(version = "1.0.0", timeout = 30000, retries = 0)
    private IMchsubQueryService iMchsubQueryService;

    private final MyLog _log = MyLog.getLog(MchsubBindBanKcardCtr.class);

    /**
     * @param data,sign
     * @Description: 查询子商户
     * @author wzc
     * @date 2018/7/23 10:52
     */
    @RequestMapping(value = "/api/pay/selectMachAccNo.htm")
    @Parameter
    public String selectMachAccNo(String data, String sign) {
        try {
            MchsubQueryEs card = JSONObject.parseObject(StringEscapeUtils.unescapeJava(data), MchsubQueryEs.class);
            MchsubQueryEs req = iMchsubQueryService.mchsubQueryHandle(card, sign);
            return ClassRefUtil.createRetData(card, req, PayConstant.RETURN_DEPOSIT_SUCESS, PayConstant.RETURN_ALIPAY_VALUE_SUCCESS);
        } catch (Exception e) {
            _log.error(e, "数据格式有误！");
            return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_DEPOSIT_CARD_ERROR, "数据格式有误！", null, null));
        }
    }
}
